package com.lbg.drug.controller;

import com.lbg.drug.commont.untils.PageUtils;
import com.lbg.drug.commont.untils.R;
import com.lbg.drug.dto.DrugPage;
import com.lbg.drug.entity.DrugCategory;
import com.lbg.drug.service.DrugCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  药品类名信息表
 * </p>
 *
 * @author lbg1
 * @since 2022-04-26
 */
@Api(value="药品类名信息表",tags={"药品类名信息表"})
@RestController
@RequestMapping("/drug-category")
public class DrugCategoryController {


    @Autowired
    private DrugCategoryService d;

    @PostMapping ("/getDrugFacts")
    public R getDrugFacts(@RequestBody DrugPage drugPage){
        PageUtils drug = d.getDrug(drugPage);
        return R.ok().put("drug",drug);

    }
    @PostMapping ("/addDrugFacts")
    public R addDrugFacts(@RequestBody DrugCategory drugCategory){
        String id = d.add(drugCategory);

        return R.ok().put("id",id);

    }

    @GetMapping("/remove")
    public R remove(String id){
       d.delete(id);
        return R.ok();

    }
    @PostMapping("/updats")
    public R updats(@RequestBody DrugCategory drugCategory){
        d.update(drugCategory);
        return R.ok();

    }



}

